<?php

namespace Home\Controller;

use Think\Controller;

use Home\Lib\Uploader;

class ExampleController extends Controller
{
    public function index()
    {
        $this->display();
    }

    public function upload()
    {
        $uploader = new Uploader([
            'path' => C('UPLOAD_PATH'),
            'types' => [
                'image/jpeg' => 'jpg',
                'image/jpg' => 'jpg'
            ]
        ]);

        if (!isset($_FILES['file'])) {
            exit;
        }

        $result = $uploader->uplaod($_FILES['file']);
        die(json_encode($result));
    }
}
